+2007-12-10 Richard Hult <richard@imendio.com>
+
+ * gdk/quartz/gdkdrawable-quartz.c:
+ (gdk_quartz_drawable_get_context),
+ (gdk_quartz_drawable_release_context):
+ * gdk/quartz/gdkeventloop-quartz.c: (gdk_event_prepare),
+ (gdk_event_check), (gdk_event_dispatch), (poll_func):
+ * gdk/quartz/gdkwindow-quartz.h: Replace the autorelease pools
+ used for each drawing context and in prepare, dispatch and poll
+ with one that exists across each main loop iteration. Fixes leaks
+ on leopard and protects against future leaks introduce when the
+ underlying system changes again (bug #492977).
+
2007-12-10 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkwindow-quartz.c: (move_resize_window_internal):
*/
if (window_impl->in_paint_rect_count == 0)
{
- window_impl->pool = [[NSAutoreleasePool alloc] init];
if (![window_impl->view lockFocusIfCanDraw])
- {
- [window_impl->pool release];
- window_impl->pool = NULL;
-
- return NULL;
- }
+ return NULL;
}
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
/* See comment in gdk_quartz_drawable_get_context(). */
if (window_impl->in_paint_rect_count == 0)
- {
- [window_impl->view unlockFocus];
-
- if (window_impl->pool)
- {
- [window_impl->pool release];
- window_impl->pool = NULL;
- }
- }
+ [window_impl->view unlockFocus];
}
else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))
CGContextRelease (cg_context);
static guint n_pollfds;
static CFRunLoopSourceRef select_main_thread_source;
static CFRunLoopRef main_thread_run_loop;
+static NSAutoreleasePool *autorelease_pool;
gboolean
_gdk_quartz_event_loop_check_pending (void)
GDK_THREADS_ENTER ();
- GDK_QUARTZ_ALLOC_POOL;
-
*timeout = -1;
event = [NSApp nextEventMatchingMask: NSAnyEventMask
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
event != NULL);
- GDK_QUARTZ_RELEASE_POOL;
-
GDK_THREADS_LEAVE ();
return retval;
GDK_THREADS_ENTER ();
+ if (autorelease_pool)
+ [autorelease_pool release];
+ autorelease_pool = [[NSAutoreleasePool alloc] init];
+
if (_gdk_event_queue_find_first (_gdk_display) != NULL ||
_gdk_quartz_event_loop_check_pending ())
retval = TRUE;
GDK_THREADS_ENTER ();
- GDK_QUARTZ_ALLOC_POOL;
-
_gdk_events_queue (_gdk_display);
event = _gdk_event_unqueue (_gdk_display);
gdk_event_free (event);
}
- GDK_QUARTZ_RELEASE_POOL;
-
GDK_THREADS_LEAVE ();
return TRUE;
int n_active = 0;
int i;
- GDK_QUARTZ_ALLOC_POOL;
-
if (nfds > 1)
{
if (!select_thread) {
n_active ++;
}
- GDK_QUARTZ_RELEASE_POOL;
-
return n_active;
}
old_poll_func = g_main_context_get_poll_func (NULL);
g_main_context_set_poll_func (NULL, poll_func);
-
+
+ autorelease_pool = [[NSAutoreleasePool alloc] init];
}
GdkWindowTypeHint type_hint;
- /* This is the autorelease pool which is retained
- * while the context is being held
- */
- NSAutoreleasePool *pool;
-
NSCursor *nscursor;
GdkRegion *paint_clip_region;